package action.sbk_jjgl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import services.sbk_jjgl.KcjjServices;
import com.util.Component;
import com.PublicSystem;
import com.util.Util;
import com.syslog.SysLogServices;
/**
 * 卡厂付款登记
 * @author host
 *
 */
@Controller
@RequestMapping("kid.do")
public class KcjjAction {
	SysLogServices log = SysLogServices.getInstance();
	KcjjServices ss = new KcjjServices();
	PublicSystem sys = PublicSystem.getInstance();
	/**
	 * 银行下拉框选项
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(params = "method=getyinhang")
	public void getYinhang(HttpServletRequest request, HttpServletResponse response) throws Exception {
		List data = ss.getYinhang(Component.getQuest("sj", request));
		Component.print(Util.Encode(data), response);
	}		
	/**
	 * 卡商下拉框选项
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(params = "method=getzkks")
	public void getzkks(HttpServletRequest request, HttpServletResponse response) throws Exception {
		List data = ss.getzkks();
		Component.print(Util.Encode(data), response);
	}	
	/**
	 * 卡商联系人
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(params = "method=getkslxr")
	public void getkslxr(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String data = ss.getkslxr(Component.getQuest("ksid", request));
		Component.print(data, response);
	}
	/**
	 * 卡厂付款登记查询
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(params = "method=getunit")
	public void getunit(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String key1 = Component.getQuest("key1", request);
		String key2 = Component.getQuest("key2", request);
		HashMap parms = sys.getGridSort(request);
		String json = Util.Encode(ss.getUnit(new Object[] {key1, key2}, parms));
		String userid = Component.getSession("userid", request);
		HashMap obj = new HashMap();
		obj.put("domainid", "SBK");  //分系统号，见sys_log_bm
		obj.put("log_type", "T05");   //日志类别，见sys_log_bm
		obj.put("userid", userid); //操作人
		obj.put("rwh", Component.getSession("rwid", request));	      //任务号（菜单号），取Component.getSession("rwid", request),若特殊则为空为自定义
		obj.put("content", "制卡批次为：" + key1 + "的卡厂付款登记修改");  //日志内容，自己组合拼装
		obj.put("czqd", "Q1");	      //操作渠道，见sys_log_bm
		obj.put("czrlb", "L01");      //操作人类别，见sys_log_bm
		obj.put("datain", "制卡批次为："+ key1 + "银行为：" + key2); //输入参数
		obj.put("dataout", "success");//输出参数
		log.sysLogMap(obj, request); 			
		Component.print(json, response);
	}		
	/**
	 * 到卡数量
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(params = "method=getnumber")
	public void getnumber(HttpServletRequest request, HttpServletResponse response) throws Exception {	
		String id = Component.getQuest("id", request);
		String bank = Component.getQuest("bank", request);			
		HashMap json = ss.getnumber(new Object[] {id, bank});
		Component.print(Util.Encode(json), response);
	}
	/**
	 * 到卡数量
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(params = "method=getnumber1")
	public void getnumber1(HttpServletRequest request, HttpServletResponse response) throws Exception {	
		String id = Component.getQuest("id", request);
		String bank = Component.getQuest("bank", request);			
		HashMap json = ss.getnumber1(new Object[] {id, bank});
		Component.print(Util.Encode(json), response);
	}
	/**
	 * 导出数据量
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(params = "method=getdcnumber")
	public void getdcnumber(HttpServletRequest request, HttpServletResponse response) throws Exception {	
		String aaz001 = Component.getQuest("aaz001", request);
		String aae008 = Component.getQuest("aae008", request);			
		HashMap json = ss.getdcnumber(aaz001, aae008);
		Component.print(Util.Encode(json), response);
	}
	/**
	 * 卡厂付款登记
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(params ="method=kcfkdj")
	public void kcfkdj(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String idreturn = "";
		String json = Component.getQuest("data", request);	
		String userid = Component.getSession("userid", request);
		ArrayList rows = (ArrayList)Util.Decode(json);
		HashMap row = (HashMap)rows.get(0);	 
		HashMap obj = new HashMap();
		row.put("userid", userid);
		obj.put("domainid", "SBK");  //分系统号，见sys_log_bm
		obj.put("log_type", "T03");   //日志类别，见sys_log_bm
		obj.put("userid", userid); //操作人
		obj.put("rwh", Component.getSession("rwid", request));	      //任务号（菜单号），取Component.getSession("rwid", request),若特殊则为空为自定义
		obj.put("content", "制卡批次为：" + row.get("aaz001").toString() + "的卡厂付款登记");  //日志内容，自己组合拼装
		obj.put("czqd", "Q1");	      //操作渠道，见sys_log_bm
		obj.put("czrlb", "L01");      //操作人类别，见sys_log_bm
		obj.put("datain", json); //输入参数
		obj.put("dataout", "success");//输出参数
		log.sysLogMap(obj, request);
		idreturn=ss.kcfkdj(row);
	    Component.print(idreturn, response);
	} 	
	/**
	 * 交卡长制卡登记
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(params ="method=jkczkdj")
	public void jkczkdj(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String idreturn = "";
		String json = request.getParameter("data");	
		ArrayList rows = (ArrayList)Util.Decode(json);
		HashMap row = (HashMap)rows.get(0);
		String aae011 = Component.getSession("userid", request);
		row.put("aae011", aae011);		
		String userid = Component.getSession("userid", request);
		HashMap obj = new HashMap();
		obj.put("domainid", "SBK");  //分系统号，见sys_log_bm
		obj.put("log_type", "T02");   //日志类别，见sys_log_bm
		obj.put("userid", userid); //操作人
		obj.put("rwh", Component.getSession("rwid", request));	      //任务号（菜单号），取Component.getSession("rwid", request),若特殊则为空为自定义
		obj.put("content", "制卡批次为：" + row.get("aaz001").toString() + "的交卡厂制卡登记");  //日志内容，自己组合拼装
		obj.put("czqd", "Q1");	      //操作渠道，见sys_log_bm
		obj.put("czrlb", "L01");      //操作人类别，见sys_log_bm
		obj.put("datain", json); //输入参数
		obj.put("dataout", "success");//输出参数
		log.sysLogMap(obj, request);		
		idreturn = ss.jkczkdj(row);
	    Component.print(idreturn, response);
	} 
}
